<?php 
	$pPageIsPublic = false;
	include '../_common.php';
	$_SESSION["m1"]="destination";
	$_SESSION["m2"]="divingstyle-list";
	
	
	$pTitle  = 'New Diving Style';
	$pButton = 'Save';
	$action  = 'add';
	$id 	 = intval($_REQUEST['id']);
	$seo	 = NULL;
	
	
	$objDs = new DivingStyle();
	$objDs ->setUid($id);
	if ($objDs ->load()) {
		$pTitle  = 'Edit Diving Style';
		$pButton = 'Update';
		$action  = 'edit';
		//$locationMap = json_decode($objDs ->locationMap);
	}
	
	if ($_GET['action']== 'del') {
		if ($objDs ->isLoaded()) {
			switch ($_GET['i']){
				case "h" :
					$objDs ->removeImage('bnImage');
					$msg = "Banner Home deleted.";
					break;
				case "b" :
					$objDs ->removeImage('bgImage');
					$msg = "Picture Page deleted.";
					break;
			}
		}
	}
	 
	if (isset($_POST['submit'])) {
		$objDs ->setAuto($_POST);
		$objDs ->uploadImage('ifile', 'bgImage');
		$objDs ->uploadImage('ifile2', 'bnImage');
		if ($_POST['action'] == 'edit') {
			$objDs ->getConnection();
			$objDs ->setUid($id);
			$objDs ->update();
			Tzn::redirect($_SERVER['PHP_SELF']."?id=". $objDs ->id, 'Diving Style has been updated.');
		} elseif ($_POST['action'] == 'add') {
			$objDs ->add();
			Tzn::redirect($_SERVER['PHP_SELF']."?id=". $objDs ->id, 'Diving Style has been added.');
		}
	}

?>
<?php include("header.php"); ?>
<style>table#toggle tr th {width: 14%;}  </style>
<script type="text/javascript">
$(document).ready(function(){
	$('#frmMain').validate();	
});
</script>
<?php include("sidebar.php"); ?>
		<ul id="subnav" class="bar" >
			<li ><a href="divingstyle-list.php" > Diving Style List </a></li>
			<li><font>&raquo;</font></li>
			<li class="noborder" ><span><?php echo $pTitle;?> </span></li>
		</ul>
<div id="list">
	<h2> <?php echo $pTitle;?> </h2>
			<form action="" method="post" name = "frmMain" id = "frmMain"  enctype="multipart/form-data" >
			<fieldset><legend> General Info </legend>
					<table cellpadding="0" cellspacing="0" class="table-form"  >
						<tr>
							<th width="14%" >Title: </th>
							<td width="86%" ><?php $objDs ->qText('title', '', 'width:548px', 'class="required"');?></td>
						</tr>
						<!--tr>
							<th>Sub Title: </th>
							<td><?php $objDs ->qText('subTitle', '', 'width:548px', 'class=""');?></td>
						</tr-->
						<tr>						
							<td colspan="2" >
						<br/>
							<label>Description: </label><?php $objDs ->qEditor('description', '', $config ); ?></td>
						</tr>
						<?php $objDs ->printSEO()  ?>
						<tr>
							<th>Banner Home : </th>
							<td>
						<?php	if ($objDs ->bnImage): ?>
								<div style="width: 230px;" class="img-border">
									<img alt="" src="../thumb.php?src=<?php echo TZN_FILE_UPLOAD_URL_ADMIN.$objDs ->bnImage?>&w=230&h=80" width="230" height="80"   ><br/>
									<a href="<?php echo $_SERVER['PHP_SELF']  ?>?action=del&i=h&id=<?php echo $objDs ->id ?>"  >delete picture</a>
								</div>
							<?php
								else:
									$objDs ->qFile('ifile2', '', '', 'class="required"'); 		
								endif; 
							?>
							</td>
						</tr>
						<tr>
							<th>Picture Page : </th>
							<td>
						<?php	if ($objDs ->bgImage): ?>
								<div style="width: 230px;" class="img-border">
									<img alt="" src="../thumb.php?src=<?php echo TZN_FILE_UPLOAD_URL_ADMIN.$objDs ->bgImage?>&w=230&h=80" width="230" height="80"   ><br/>
									<a href="<?php echo $_SERVER['PHP_SELF']  ?>?action=del&i=b&id=<?php echo $objDs ->id ?>"  >delete picture</a>
								</div>
							<?php
								else:
									$objDs ->qFile('ifile', '', '', 'class="required"'); 		
								endif; 
							?>
							</td>
						</tr>
						<tr>
							<th>Status: </th>
							<td><?php $objDs ->arrayToSelect($objDs ->_arrStatus, 'status', $objDs ->status, false, 'width:100px', '');?></td>
						</tr>
					</table>
			</fieldset>
			<div style="margin-top:10px">
				<input type="hidden" name="id" value="<?php echo $id; ?>" />
				<input type="hidden" name="action" value="<?php echo $action; ?>" />
                <input type="submit" name="submit"  value="<?php echo $pButton; ?>" /> &nbsp; <input type="reset" value="Cancel" onClick="window.location.href='divingstyle-list.php'" />
            </div>
            </form>
</div>
<?php include("footer.php"); ?>